package dp.ua.epic.test.webapp;

import dp.ua.epic.webapp.EpicApplication;
import epic.services.HeroService;
import org.apache.wicket.application.IComponentInstantiationListener;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import org.apache.wicket.spring.injection.annot.test.AnnotApplicationContextMock;
import org.mockito.Mockito;

/**
 * Mocked {@link EpicApplication} for testing purpose.
 *
 * @author Artem
 */
public class SpringMockedTestApplication extends EpicApplication {
 
    private HeroService heroServiceMock = Mockito.mock(HeroService.class);
    
    @Override
    protected IComponentInstantiationListener getSpringComponentInjector(WebApplication application) {
        AnnotApplicationContextMock applicationContextMock = new AnnotApplicationContextMock();
        applicationContextMock.putBean(heroServiceMock);
        return new SpringComponentInjector(application, applicationContextMock, true);
    }

    public void setHeroService(HeroService heroServiceMock) {
        this.heroServiceMock = heroServiceMock;
    }
}
